<?php
session_start();
/*$player = new player;
$rp = new rp;

$standings = $player->get();

$points = $rp->get();

$smarty->assign('standings', $standings);
$smarty->assign('rp', $points);*/

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");    // Datum in het verleden
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
                                                     // Altijd veranderd
header("Cache-Control: no-store, no-cache, must-revalidate");  // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");                          // HTTP/1.0

require('./core/Smarty_oRs.php');
require('./includes/config.php');
require('./includes/func_database.php');
require('./includes/func_signups.php');
require('./includes/func_event.php');
require('./includes/func_raid.php');

$dbh = initConnection();

$signup = new signup();
$raid = new raid();
$event = new event();


$smarty = new Smarty_oRs;


$type = $_GET['type'];

$value = $_GET['value'];

/*
foreach ($events as $event_key => $single_event) {
	
	
	$global_signups[$single_event['event_id']]['year']['sub'] = $signup->getYearHistory(0, 0, $single_event['event_id']);
	
	$global_signups[$single_event['event_id']]['year']['main'] = $signup->getYearHistory(0, 1, $single_event['event_id']);

	$global_signups[$single_event['event_id']]['month']['sub'] = $signup->getMonthHistory(0, 0, $single_event['event_id']);
	
	$global_signups[$single_event['event_id']]['month']['main'] = $signup->getMonthHistory(0, 1, $single_event['event_id']);
	
	$global_signups[$single_event['event_id']]['week']['sub'] = $signup->getWeekHistory(0, 0, $single_event['event_id']);
	
	$global_signups[$single_event['event_id']]['week']['main'] = $signup->getWeekHistory(0, 1, $single_event['event_id']);
	
	
	$user_signups[$single_event['event_id']]['year']['sub'] = $signup->getYearHistory($armory_player[0]['user_id'], 0, $single_event['event_id']);
	
	$user_signups[$single_event['event_id']]['year']['main'] = $signup->getYearHistory($armory_player[0]['user_id'], 1, $single_event['event_id']);

	$user_signups[$single_event['event_id']]['month']['sub'] = $signup->getMonthHistory($armory_player[0]['user_id'], 0, $single_event['event_id']);
	
	$user_signups[$single_event['event_id']]['month']['main'] = $signup->getMonthHistory($armory_player[0]['user_id'], 1, $single_event['event_id']);
	
	$user_signups[$single_event['event_id']]['week']['sub'] = $signup->getWeekHistory($armory_player[0]['user_id'], 0, $single_event['event_id']);
	
	$user_signups[$single_event['event_id']]['week']['main'] = $signup->getWeekHistory($armory_player[0]['user_id'], 1, $single_event['event_id']);
	
/*
	$main_history = $signup->getHistory($armory_player[0]['user_id'], 0, $single_event['event_id']);
	
	$events[$event_key]['main_signed_up'] = count($main_history);
	
	foreach ($main_history as $main_key => $main_item) {
		
		$events[$event_key][$main_item['year']][$main_item['month']][$main_item['week']] = $main_item;
		
	}
	
	$sub_history = $signup->getHistory($armory_player[0]['user_id'], 1, $single_event['event_id']);
	
	$events[$event_key]['sub_signed_up'] = count($sub_history);
	
	foreach ($sub_history as $sub_key => $sub_item) {
		
		$events[$event_key][$sub_item['year']][$sub_item['month']][$sub_item['week']] = $sub_item;
		
	}*/

/*echo "<pre>";
print_r($global_signups);
echo "</pre>";
*/

//$global_statistics = $signup->getHistory($type, $value);

$from = $_GET['from'];

$to = $_GET['to'];


$global_statistics = $signup->getHistory($type, 0, 0, $from, $to);


$user_statistics['main'] = $signup->getHistory($type, $value, 0, $from, $to);


$user_statistics['sub'] = $signup->getHistory($type, $value, 1, $from, $to);


$actual_statistics = $signup->getActualHistory($type, $value, 1, $from, $to);


$smarty->assign('actual_statistics', $actual_statistics);

$smarty->assign('global_statistics', $global_statistics);

$smarty->assign('user_statistics', $user_statistics);

$smarty->display('statistics.tpl', $_SESSION['uid']);

?>
